import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{
		//公共变量，不能随意修改，通过触发mutation修改
		userInfo:{},
		hasLogin:false,
	},
	mutations:{
		login(state,provider){
			console.log(123456);
			state.hasLogin = true;
			state.userInfo.token = provider.token;
			state.userInfo.userName = provider.user_name;
			uni.setStorageSync({
				key:"userInfo",
				data:provider,
			})
			console.log("扥估");
		},
		logout(state){
			state.hasLogin = false;
			state.userInfo = {};
			uni.removeStorageSync({
				key:"userInfo"
			})
			console.log("的鞥出");
		}
	}
	
})